<?php

namespace App\Http\Controllers\V1\Api;

use App\Models\V1\Advert;

use App\Models\V1\News;
use Illuminate\Http\Request;

class AdvertController extends BaseController
{

    /**
     * 广告列表-api
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $sort = $request->input('sort', 'id');
        $order = $request->input('order', 'desc');
        $pageSize = $request->input('pageSize', 10);
        $query = Advert::query();
        $query->where('advert_place_id', $request->input('advert_place_id', 0));
        $query->where('state',1);
        $query->orderBy($sort, $order);
        $data = $query->paginate($pageSize);
        return ajax_output(200, "成功", $data);
    }


    /**
     * 盒子广告详情
     *
     * @param int $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $data = Advert::find($id);
        if (!$data) {
            return ajax_output(300, "数据不存在");
        }
        return ajax_output(200, "成功", $data);
    }


}
